package com.dqhl.community.adapter;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.dqhl.community.R;
import com.dqhl.community.base.BaseMyAdapter;
import com.dqhl.community.model.HealthRecordBean;
import com.dqhl.community.util.TimeUtils;

import java.util.List;

/**
 * Created by LIENLIN on 2016/9/11.
 */
public class HealthRecordAdapter extends BaseMyAdapter {
    List<HealthRecordBean> list;
    public HealthRecordAdapter(Context context, List<HealthRecordBean> list) {
        super(context);
        this.list=list;
    }

    @Override
    public int getCount() {
        Log.d("HealthRecordAdapter","list.size()="+list.size());
        return list.size();
    }
    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }
    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {

        View v = inflater.inflate(R.layout.lv_item_health_record, viewGroup, false);
        TextView tvTopLeft = (TextView) v.findViewById(R.id.tv_community);
        TextView tvTopRight = (TextView) v.findViewById(R.id.tv_time);
        TextView tvName = (TextView) v.findViewById(R.id.tv_owner_name);
        TextView tvIll = (TextView) v.findViewById(R.id.tv_ill);
        TextView tvRecordTime = (TextView) v.findViewById(R.id.tv_yuyue_time);

        HealthRecordBean healthRecordBean = list.get(i);
        tvTopLeft.setText(healthRecordBean.getId());
        tvTopRight.setText(TimeUtils.timeStamp2Date(healthRecordBean.getCreate_time(),"yyyy-MM-dd HH:mm"));
        tvName.setText(healthRecordBean.getUser_name());
        tvIll.setText(healthRecordBean.getIllness_type());
        tvRecordTime.setText(TimeUtils.timeStamp2Date(healthRecordBean.getStart_time(),"yyyy-MM-dd HH:mm"));

        return v;
    }
}
